package com.gy.education.home.adapter;

import android.content.Context;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.ImageView;
import android.widget.TextView;

import com.gy.education.R;
import com.gy.education.home.bean.MessageBean;

import java.util.List;

/**
 * 作者：gy on 16/7/13
 * 说明：
 */
public class MyMessageAdapter extends BaseAdapter {

    private Context context;
    private List<MessageBean> list;

    public MyMessageAdapter(Context context,List<MessageBean> list){
        this.context = context;
        this.list = list;
    }

    @Override
    public int getCount() {
        return list.size();
    }

    @Override
    public Object getItem(int i) {
        return null;
    }

    @Override
    public long getItemId(int i) {
        return 0;
    }

    @Override
    public View getView(int i, View view, ViewGroup viewGroup) {
        ViewHolder holder;
        if(view == null){
            holder = new ViewHolder();
            view = View.inflate(context, R.layout.adapter_my_message,null);
            holder.imgFlag = (ImageView) view.findViewById(R.id.adapter_message_img);
            holder.tvTitle = (TextView) view.findViewById(R.id.adapter_message_tv_title);
            holder.tvTime = (TextView) view.findViewById(R.id.adapter_message_tv_time);
            holder.tvContent = (TextView) view.findViewById(R.id.adapter_message_tv_content);
            view.setTag(holder);
        } else {
            holder = (ViewHolder) view.getTag();
        }
        if(i % 3 == 0){
            holder.imgFlag.setImageResource(R.mipmap.ic_home_csgw);
        } else if(i % 3 == 1){
            holder.imgFlag.setImageResource(R.mipmap.ic_home_lt);
        } else {
            holder.imgFlag.setImageResource(R.mipmap.ic_home_scwm);
        }
        return view;
    }

    class ViewHolder{
        ImageView imgFlag;
        TextView tvTitle,tvTime,tvContent;
    }
}
